"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const redux_1 = require("@tarojs/redux");
const taro_1 = require("@tarojs/taro");
const taro_ui_1 = require("taro-ui");
const HomeShare_1 = require("../../containers/HomeShare");
const HomeContent_1 = require("../../containers/HomeContent");
const HomeHandle_1 = require("../../containers/HomeHandle");
const XPage_1 = require("../../components/XPage");
const goods_1 = require("../../actions/goods");
require("./testImg.scss");
let Home = class Home extends taro_1.Component {
    constructor() {
        super(...arguments);
        this.config = {
            navigationBarTitleText: '幸运草小程序'
        };
        this.handleToPage = (params, msg) => {
            msg.stopPropagation();
            taro_1.default.navigateTo({
                url: `/pages/profile/index?id=${params.id}`
            });
        };
    }
    componentWillMount() {
        // 初始化数据
        this.props.fetchList({ type: 1, sorter: 'id_ascend' });
    }
    //分享按钮函数
    onShareAppMessage() {
        return {
            title: '幸运草小程序',
            path: 'pages/home/index?userId=0',
            success(res) {
                console.log("转发成功:" + JSON.stringify(res));
            },
            fail(res) {
                console.log("转发失败:" + JSON.stringify(res));
            }
        };
    }
    render() {
        return (<XPage_1.default>
        <HomeShare_1.default />
        {this.props.goods.isLoading
            ?
                <taro_ui_1.AtLoadMore loadingText='加载中...' status={this.props.goods.isLoading ? 'loading' : 'noMore'}/>
            :
                this.props.goods.data.data.map((row) => <HomeContent_1.default queryRow={row} key={row.id} onClick={this.handleToPage.bind(this, row)}/>)}
        <HomeHandle_1.default />
      </XPage_1.default>);
    }
};
Home = __decorate([
    redux_1.connect(({ goods }) => ({
        goods
    }), (dispatch) => ({
        fetchList(params) {
            dispatch(goods_1.queryList(params));
        }
    }))
], Home);
exports.default = Home;
//# sourceMappingURL=index.jsx.map